package com.yy.finvideoplayer.videoview

import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.util.Log
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import androidx.annotation.DrawableRes
import com.yy.finvideoplayer.R

class IndicatorView : LinearLayout {

    companion object {
        private const val TAG = "IndicatorView"
    }

    private val iconView: ImageView
    private val indicator: Indicator

    private val density = context.resources.displayMetrics.density

    constructor(context: Context?) : super(context)
    constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
        context,
        attrs,
        defStyleAttr
    )

    init {
        orientation = VERTICAL
        gravity = Gravity.CENTER
        visibility = View.GONE

        LayoutInflater.from(context).inflate(R.layout.fin_applet_layout_indicator_view, this, true)
        iconView = findViewById(R.id.icon)
        indicator = findViewById(R.id.indicator)

    }

    fun show(@DrawableRes icon: Int, max: Int) {
        iconView.setImageResource(icon)
        indicator.setMax(max)
        this.visibility = View.VISIBLE
    }

    fun hide() {
        this.visibility = View.GONE
    }

    fun setProgress(progress: Int) {
        indicator.setProgress(progress)
    }



}